home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / ParseTree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-02  |  4.2 KB  |  168 lines  |  [TEXT/ALFA]

  1. /*
  2.  * Harvest C
  3.  * 
  4.  * Copyright 1991 Eric W. Sink   All rights reserved.
  5.  * 
  6.  * This file defines the interface for parse trees.
  7.  * 
  8.  */
  9.  
  10. #ifndef ParseTree_INTERFACE
  11. #define ParseTree_INTERFACE
  12.  
  13. typedef struct ParseNode        ParseTree_t;
  14. typedef ParseTree_t P__H       *ParseTreeVia_t;
  15.  
  16. /* Parse Tree Format Codes */
  17. enum ParseTreeFormat {
  18.     PTF_array_subscript = 1,
  19.     PTF_function_call,
  20.     PTF_message_send,
  21.     PTF_postincrement,
  22.     PTF_postdecrement,
  23.     PTF_argument_list,
  24.     PTF_preincrement,
  25.     PTF_predecrement,
  26.     PTF_address_of,
  27.     PTF_gen_addrof,
  28.     PTF_deref,
  29.     PTF_unary_plus,
  30.     PTF_unary_minus,
  31.     PTF_bitwise_neg,
  32.     PTF_logical_neg,
  33.     PTF_sizeof,
  34.     PTF_enumconstant,
  35.     PTF_multiply,
  36.     PTF_divide,
  37.     PTF_modulo,
  38.     PTF_typechange,
  39.     PTF_add,
  40.     PTF_subtract,
  41.     PTF_shift_left,
  42.     PTF_shift_right,
  43.     PTF_lessthan,
  44.     PTF_greaterthan,
  45.     PTF_lessthaneq,
  46.     PTF_greaterthaneq,
  47.     PTF_equal,
  48.     PTF_notequal,
  49.     PTF_bitwise_and,
  50.     PTF_bitwise_xor,
  51.     PTF_bitwise_or,
  52.     PTF_logical_and,
  53.     PTF_logical_or,
  54.     PTF_ternary,
  55.     PTF_assign,
  56.     PTF_mulassign,
  57.     PTF_divassign,
  58.     PTF_modassign,
  59.     PTF_addassign,
  60.     PTF_subassign,
  61.     PTF_leftassign,
  62.     PTF_rightassign,
  63.     PTF_andassign,
  64.     PTF_xorassign,
  65.     PTF_orassign,
  66.     PTF_commas,
  67.     PTF_multi_initializer,
  68.     PTF_initializer_list,
  69.     PTF_exprstmt,
  70.     PTF_emptystmt,
  71.     PTF_switchcase_stmt,
  72.     PTF_switchdefault_stmt,
  73.     PTF_compound_stmt,
  74.     PTF_stmt_list,
  75.     PTF_ifthenelse_stmt,
  76.     PTF_switch_stmt,
  77.     PTF_while_stmt,
  78.     PTF_dowhile_stmt,
  79.     PTF_for_stmt,
  80.     PTF_continue_stmt,
  81.     PTF_break_stmt,
  82.     PTF_return_stmt,
  83.     PTF_identifier,
  84.     PTF_intconstant,
  85.     PTF_floatconstant,
  86.     PTF_string_literal,
  87.     PTF_struct_member,
  88.     PTF_struct_indirect_member,
  89.     PTF_labelled_stmt,
  90.     PTF_goto_stmt,
  91.     PTF_NOP,
  92.     PTF_asm_stmt
  93. };
  94.  
  95. #include "TypeRecord.h"
  96. #include "SymTable.h"
  97. #include "FloatLit.h"
  98. #include "CodeGen.h"
  99. #include "Scopes.h"
  100. #include "AbsString.h"
  101.  
  102.  
  103. /* ------------------ Parse Trees ------------------ */
  104.  
  105. /*
  106.  * Below, the structure declaration for Parse Tree nodes.  This structure is
  107.  * used to construct expression trees and statement trees. Each node has a
  108.  * code associated with it, which specifies the meaning of the various
  109.  * fields. The 'kind' field of the nodes in the parse tree indicates the
  110.  * contents of the node.  It may take on any of the values usually used for
  111.  * tokens, in which case it indicates that the node is a leaf of the parse
  112.  * tree, and a terminal symbol.  Or, it may take on a value indicating that
  113.  * it is the parent of several other nodes. Each production in the grammar
  114.  * for this parser has a node format associated with it, and a token code
  115.  * associated with that format. The 'TP' field is used for assigning the
  116.  * types of expressions.
  117.  */
  118.  
  119. struct ParseNode {
  120.     enum ParseTreeFormat            kind;
  121.     short                           LValue;
  122.     ParseTreeVia_t                  a;
  123.     ParseTreeVia_t                  b;
  124.     ParseTreeVia_t                  c;
  125.     union {
  126.     ScopesVia_t                     Scopes;
  127.     ParseTreeVia_t                  d;
  128.     TypeRecordVia_t                 TP;
  129.     }                               for_Scopes;
  130.     union TokenValue {
  131.     InstListVia_t                   AsmCodes;    /* TODO needs disposal */
  132.     SYMVia_t                        SLit;    /* don't dispose, an alias in
  133.                          * stringlits */
  134.     FloatLitVia_t                   FLit;    /* same as slit */
  135.     long                            number;
  136.     TypeRecordVia_t                 TP;
  137.     SYMVia_t                        thesymbol;    /* don't dispose, in
  138.                              * some symbol table */
  139.     AbsStringID                     identifier;
  140.     }                               data;
  141. };
  142.  
  143. ParseTreeVia_t
  144. GetTreeFour(ParseTreeVia_t tree);
  145.  
  146. ScopesVia_t
  147. GetTreeScopes(ParseTreeVia_t tree);
  148.  
  149. void
  150.                                 SetTreeFour(ParseTreeVia_t tree, ParseTreeVia_t d);
  151.  
  152. void
  153.                                 SetTreeScopes(ParseTreeVia_t tree, ScopesVia_t s);
  154.  
  155. void
  156.                                 SetTreeTP(ParseTreeVia_t tree, TypeRecordVia_t TP);
  157.  
  158. TypeRecordVia_t
  159. GetTreeTP(ParseTreeVia_t tree);
  160.  
  161. short
  162.                                 GetTreeLValue(ParseTreeVia_t tree);
  163.  
  164. void
  165.                                 SetTreeLValue(ParseTreeVia_t tree, short v);
  166.  
  167. #endif
  168.